package com.mmsj;

import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class ContextMenuActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_context_menu);
        Button button = findViewById(R.id.button);
        registerForContextMenu(button);
    }
    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        getMenuInflater().inflate(R.menu.my_menu, menu);
        super.onCreateContextMenu(menu, v, menuInfo);
    }
    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        int id = item.getItemId();
        if(id == R.id.menu_item_1)
            Toast.makeText(this, "menu_item_1", Toast.LENGTH_SHORT).show();
        else if(id == R.id.menu_item_2)
            Toast.makeText(this, "menu_item_2", Toast.LENGTH_SHORT).show();
        else if(id == R.id.menu_item_3)
            Toast.makeText(this, "menu_item_3", Toast.LENGTH_SHORT).show();
        else if (id == R.id.menu_item_4)
            Toast.makeText(this, "menu_item_4", Toast.LENGTH_SHORT).show();
        else if (id == R.id.menu_item_5)
            Toast.makeText(this, "menu_item_5", Toast.LENGTH_SHORT).show();
        return super.onOptionsItemSelected(item);
    }
}